﻿@model List<LeadMaster.Models.LeadStatQuestions>

<div>
<table class="listtable contactstable" cellspacing="0" cellpadding="0" style="width: 1100px;" id="enquirylist">
<thead>
    <tr>
    <th class="tableheader">Question</th>
    <th class="tableheader">Answer Type</th>
    <th class="tableheader">Char</th>
    <th class="tableheader">Logic</th>
    <th class="tableheader">Num From</th>
    <th class="tableheader">Num To</th>
    <th class="tableheader">Mandatory</th>
    <th class="tableheader">Display Order</th>
    <th class="tableheader"></th>
    </tr>
</thead>
@foreach (var item in Model)
{
    <tr>
    <td><label class="selectstatquestion" data-statquestionid="@(item.LeadStatQuestionsID)" style="cursor: pointer; color: #333333;">@item.Question</label></td>
    <td><label>@item.AnswerType</label></td>
    <td><label>
    @if (item.AcceptedAnswerChar != null && item.AcceptedAnswerChar.Length>49)
    {
        @item.AcceptedAnswerChar.Substring(0, 50) 
        @:...
    }
    else
    {
        @item.AcceptedAnswerChar
    }
    </label></td>
    <td><label>@item.AcceptedAnswerBool</label></td>
    <td><label>@item.AcceptedAnswerIntFrom</label></td>
    <td><label>@item.AcceptedAnswerIntTo</label></td>
    <td><label>@item.Mandatory</label></td>
    <td><label>@item.DisplayOrder</label></td>
    <td><img src="~/Images/delete.ico" style="width: 20px; height: 20px" class="deletestatquestion" data-statquestionid="@(item.LeadStatQuestionsID)"/></td>
    </tr>
}
</table>
</div>

<input id="btnAskStatQuestions" type="button" value="Create Question" data-leadstatid="@(ViewBag.LeadStatID)"/>

<div id="askstatquestions">
</div>

<script type="text/javascript">
    $(document).ready(function () {

    $("#askstatquestions").dialog(
    {
        autoOpen: false,
        width: 1100,
        open: function () { $(".ui-dialog").css("box-shadow", "#000 5px 5px 5px"); },
        position:['middle',20],
        modal: true,
        dialogClass: 'notitle',
        buttons: {
            save: function () {
                $(this).dialog("close");
                $("#formAskStatQuestion").submit();
            },
            cancel: function () {
                $(this).dialog("close");
            }
        }
    });

    $("#btnAskStatQuestions").click(function () {
        $("#askstatquestions").dialog("open");
        $('#askstatquestions').html('<div style="text-align: center;"><div><img src="@Url.Content("~/Images/ajaxspinner_large.gif")" alt="Loading..." style="margin: 20px;" /></div><div>Loading...</div></div>');
        var contactURL = '@(Url.Action("CreateStatQuestions", "LeadBuilder"))/?id=' + $(this).data("leadstatid");
        $('#askstatquestions').load(contactURL);
    });

    $(".deletestatquestion").click(function () {
        var ans = confirm("Are you sure you wish to delete this question ?")
        if (ans == true) {
            var contactURL = '@(Url.Action("DeleteStatQuestion", "LeadBuilder"))/?id=' + $(this).data("statquestionid");
            $('#statquestions').load(contactURL);
        }
    });

    $(".selectstatquestion").click(function () {
        $("#askstatquestions").dialog("open");
        $('#askstatquestions').html('<div style="text-align: center;"><div><img src="@Url.Content("~/Images/ajaxspinner_large.gif")" alt="Loading..." style="margin: 20px;" /></div><div>Loading...</div></div>');
        var contactURL = '@(Url.Action("EditStatQuestion", "LeadBuilder"))/?id=' + $(this).data("statquestionid");
        $('#askstatquestions').load(contactURL);
    });

    });
</script>